package com.ykzb.talent.model;

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.ykzb.enums.QiniuBucket;
import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class Talent {

	private long id;
	private long userId;
	private String name;
	private String postOffice;
	private int talentClassId;
	private String email;
	private String introduction;
	private String position;
	@JsonIgnore
	private String resourceKey;
	@JsonIgnore
	private int resourceV;

	private String imgurl;
	private int cityCode;
	private int provinceCode;
	private Date createTime;
	private Date updateTime;
	private int state;
	

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	private int deliberately;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPostOffice() {
		return postOffice;
	}

	public void setPostOffice(String postOffice) {
		this.postOffice = postOffice;
	}

	public int getTalentClassId() {
		return talentClassId;
	}

	public void setTalentClassId(int talentClassId) {
		this.talentClassId = talentClassId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public String getResourceKey() {
		return resourceKey;
	}

	public void setResourceKey(String resourceKey) {
		this.resourceKey = resourceKey;
	}

	public int getResourceV() {
		return resourceV;
	}

	public void setResourceV(int resourceV) {
		this.resourceV = resourceV;
	}

	public int getCityCode() {
		return cityCode;
	}

	public void setCityCode(int cityCode) {
		this.cityCode = cityCode;
	}

	public int getProvinceCode() {
		return provinceCode;
	}

	public void setProvinceCode(int provinceCode) {
		this.provinceCode = provinceCode;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getImgurl() {
		if (StringUtils.isNotBlank(resourceKey)) {
			Pattern p = Pattern.compile("^http://.*|^https://.*");
			Matcher m = p.matcher(resourceKey);
			if (m.matches()) {
				return resourceKey;
			}

			return QiniuBucket.HEAD_IMG.getDomain() + resourceKey + "?v=" + resourceV;
		}

		return "";
	}

	public int getDeliberately() {
		return deliberately;
	}

	public void setDeliberately(int deliberately) {
		this.deliberately = deliberately;
	}

	@Override
	public String toString() {
		return "Talent [id=" + id + ", userId=" + userId + ", name=" + name + ", postOffice=" + postOffice
				+ ", talentClassId=" + talentClassId + ", email=" + email + ", introduction=" + introduction
				+ ", position=" + position + ", resourceKey=" + resourceKey + ", resourceV=" + resourceV + ", imgurl="
				+ imgurl + ", cityCode=" + cityCode + ", provinceCode=" + provinceCode + ", createTime=" + createTime
				+ ", updateTime=" + updateTime + "]";
	}

}
